package com.xiaoxx.coin.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum SideEnum {
    // 订单方向枚举
    BUY("BUY", "买入"),
    SELL("SELL", "卖出");

    // 订单方向代码
    @EnumValue
    private String side;
    // 订单方向描述
    private String description;


    // 根据订单方向代码获取枚举
    public static SideEnum ofSide(String side) {
        for (SideEnum sideEnum : SideEnum.values()) {
            if (sideEnum.getSide().equalsIgnoreCase(side)) {
                return sideEnum;
            }
        }
        throw new IllegalArgumentException("无效的订单方向: " + side);
    }
}
